package com.qdxwx.data.service.course;

import com.qdxwx.data.mapper.course.CoursePackageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Qdx NetSchool Platform
 * @author qdxwx
 * @updateTime 2022/5/25
 * @description
 */
@Service
public class CoursePackageServiceImpl implements CoursePackageService {
    @Autowired
    private CoursePackageMapper coursePackageMapper;

    public List<Integer> getChildIds(int courseId) {
        return coursePackageMapper.selectChildIds(courseId);
    }

    @Override
    public int insert(int courseId, int childId) {
        if (get(courseId, childId) == null) {
            return coursePackageMapper.insertCoursePackage(courseId, childId);
        }
        return 0;
    }

    @Override
    public int delete(int courseId, int childId) {
        if (courseId < 1 || childId < 1) return 0;
        return coursePackageMapper.deleteCoursePackage(courseId, childId);
    }

    @Override
    public Integer get(int courseId, int childId) {
        if (courseId < 1 || childId < 1) return null;
        return coursePackageMapper.selectCoursePackage(courseId, childId);
    }
}